package com.towncoder.service.impl;

import com.towncoder.mapper.VehicleDao;
import com.towncoder.entity.Vehicle;
import com.towncoder.service.VehicleService;
import jakarta.annotation.Resource;

import org.springframework.stereotype.Service;

/**
 * 车辆表(Vehicle)表服务实现类
 *
 * @author makejava
 * @since 2024-08-22 15:08:53
 */
@Service("vehicleService")
public class VehicleServiceImpl implements VehicleService {
    @Resource
    private VehicleDao vehicleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Vehicle queryById(Long id) {
        return this.vehicleDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param vehicle 实例对象
     * @return 实例对象
     */
    @Override
    public Vehicle insert(Vehicle vehicle) {
        this.vehicleDao.insert(vehicle);
        return vehicle;
    }

    /**
     * 修改数据
     *
     * @param vehicle 实例对象
     * @return 实例对象
     */
    @Override
    public Vehicle update(Vehicle vehicle) {
        this.vehicleDao.update(vehicle);
        return this.queryById(vehicle.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.vehicleDao.deleteById(id) > 0;
    }
}
